CIE: Use cbrt instead of pow for the reference XYZ to LAB conversion
authorDebarshi Ray <debarshir@gnome.org>
Tue, 31 Oct 2017 08:36:39 +0000 (09:36 +0100)
committerØyvind Kolås <pippin@gimp.org>
Tue, 31 Oct 2017 12:08:43 +0000 (13:08 +0100)
The fast-paths use an inlining-friendly version of cbrt(3). Using
something similar removes superficial differences between the two
conversion paths. It's not like the C library's cbrt(3) will perform
any worse than its own pow(3).

https://bugzilla.gnome.org/show_bug.cgi?id=789695

extensions/CIE.c

index a010f0b1ac331e662d0469832c7e9dff660fce9f..e93b9850a4530a3157177a905cf013827e8cfacc 100644 (file)
@@ -168,13 +168,13 @@ XYZ_to_LAB (double X,
   double y_r = Y / D50_WHITE_REF_Y;
   double z_r = Z / D50_WHITE_REF_Z;
 
-  if (x_r > LAB_EPSILON) f_x = pow(x_r, 1.0 / 3.0);
+  if (x_r > LAB_EPSILON) f_x = cbrt(x_r);
   else ( f_x = ((LAB_KAPPA * x_r) + 16) / 116.0 );
 
-  if (y_r > LAB_EPSILON) f_y = pow(y_r, 1.0 / 3.0);
+  if (y_r > LAB_EPSILON) f_y = cbrt(y_r);
   else ( f_y = ((LAB_KAPPA * y_r) + 16) / 116.0 );
 
-  if (z_r > LAB_EPSILON) f_z = pow(z_r, 1.0 / 3.0);
+  if (z_r > LAB_EPSILON) f_z = cbrt(z_r);
   else ( f_z = ((LAB_KAPPA * z_r) + 16) / 116.0 );
 
   *to_L = (116.0 * f_y) - 16.0;